/* TODO:
   Complete the class definition. Supply the body of the constructor
   and any instance fields.
*/

/**
   A rectangle whose interior is filled with a pattern
   obtained by repeating a character.
*/
public class FilledRectangle
{
   /**
      Constructs a rectangle with a given width, height, and fill
      @param aWidth the width (including the corners)
      @param aHeight the height (including the corners)
      @param aFill the fill character
   */
   private int width;
   private int height;
   private char fill;
   public FilledRectangle(int aWidth, int aHeight, char aFill)
   {
      width = aWidth;
      height = aHeight;
      fill=aFill;
   }
   public int getWidth()
   {
      return width;
   }

   /**
      Gets the height of this rectangle.
      @return the height
   */
   public int getHeight()
   {
      return height;
   }

   /**
      Prints one line of the rectangle.
      @param i the line to print (1 <= i <= height)
   */
   public void printLine(int i)
   {
      if (i == 1 || i == getHeight())
         printHelper('+', '-');
      else
         printHelper('|', fill);
   }
   public void printHelper(char boundary, char middle)
   {
      System.out.print(boundary);
      for (int j = 2; j < width; j++)
         System.out.print(middle);
      System.out.println(boundary);
   }
   public void print()
   {
      for (int i = 1; i <= height; i++)
      {
         printLine(i);         
      }
   }


   // The following method tests your class

   public static void main(String[] args)
   {
      FilledRectangle fr = new FilledRectangle(10, 7, '*');
      fr.print();
   }
}